<?php
namespace app\admin\model;
use think\Model;
use think\Db;
// 左侧导航菜单模型
class Menu extends Model{
    
	public function getMenu($power){
        // 查询数据
        $data = Db::table('功能模块')
            ->where("dbo.is_mixed(身份IDS+',5', '$power') > 0")
            ->order('顺序')
            ->select();
        $data = selectResult($data);
        
        $menudata=array();

        $arr=$this::_get_child($data);
        $json=json($arr);
        return $arr;
	}

    //菜单
    static protected function _get_child($data, $pid=0){
        $array = array();
        foreach ($data as $k => $v){
            if ($v['父级ID'] == $pid){
                $v['menus'] = self::_get_child($data, $v['ID']);
                $array[] = $v;
            }
        }
        return $array;
    }
}
